Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Threaded parallel scheme #758

Merged
merged 13 commits into from
Jul 24, 2024
Merged

Add Threaded parallel scheme #758

merged 13 commits into from
Jul 24, 2024

Conversation

odow
Copy link
Owner

@odow odow commented Jul 23, 2024

Closes #599

This is heading in the right direction:

julia> @time simulations = SDDP.simulate(
           model,
           10_000;
           parallel_scheme = SDDP.Threaded(),
           custom_recorders = Dict{Symbol, Function}(
               :thread_id => sp -> Threads.threadid(),
           ),
       );
 14.560144 seconds (58.22 M allocations: 2.101 GiB, 5.02% gc time, 0.06% compilation time)

julia> @time simulations = SDDP.simulate(
           model,
           10_000;
           parallel_scheme = SDDP.Serial(),
           custom_recorders = Dict{Symbol, Function}(
               :thread_id => sp -> Threads.threadid(),
           ),
       );
 47.935609 seconds (58.31 M allocations: 2.106 GiB, 2.24% gc time, 0.10% compilation time)

Avoiding the various race conditions is a bit fiddly though.

TODOs

  • integer stuff?

Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 85.91549% with 10 lines in your changes missing coverage. Please review.

Project coverage is 93.40%. Comparing base (430b56a) to head (f02dc91).

Files Patch % Lines
src/algorithm.jl 76.66% 7 Missing ⚠️
src/plugins/parallel_schemes.jl 88.88% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #758      +/-   ##
==========================================
- Coverage   93.44%   93.40%   -0.04%     
==========================================
  Files          27       27              
  Lines        3416     3458      +42     
==========================================
+ Hits         3192     3230      +38     
- Misses        224      228       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@odow
Copy link
Owner Author

odow commented Jul 23, 2024

So the issue is that prepare_backward_pass assumes that we will be doing only forward passes or only backward passes. We need to change this to apply per-node.

test/plugins/threaded.jl Outdated Show resolved Hide resolved
@odow odow changed the title WIP: add Threaded parallel scheme Add Threaded parallel scheme Jul 24, 2024
@odow odow mentioned this pull request Jul 24, 2024
@odow
Copy link
Owner Author

odow commented Jul 24, 2024

There's still testing to be improved, but I think this is ready for basic usage.

@odow odow merged commit 6f81951 into master Jul 24, 2024
6 of 8 checks passed
@odow odow deleted the od/threaded branch July 24, 2024 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multithreading parallelism
1 participant